<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<link rel="stylesheet" type="text/css" href="$!{basePath}/content/system/h5/css/common.css"/>
		<title></title>
		<style>
			.title{
				text-align: center;
				color: #FFCB30;
				font-size: 1.25rem;
				padding: 16px 0;
			}
			.anw{
				border: 1px solid #DCDCDC;
				border-radius: 4px;
				width: 92%;
				margin:12px auto;
			}
			.anwitem{
				display: flex;
				padding: 6px 6px;
				align-items: center;
			}
			.anwitem input{
				vertical-align:middle;

			}
			.anwitem:not(:last-child){
				border-bottom: 1px solid #dcdcdc;
			}
			.anw_text{
				margin-left: 6px;
			}
			.que_title{
				padding: 0 0 0 8px;
			}
			.but{
				width: 76%;
				background-color: #FFCB30;
				padding: 10px 0;
				text-align: center;
				color: #fff;
				border-radius: 6px;
				margin: 0 auto 20px;
			}
		</style>
	</head>
	<body>
		<div class="app">
			<form>
			<div class="title">
				<span>$!{examQuestion.name}</span>
			</div>
			<input type="hidden" name="examQues.id" value="$!{examQuestion.id}" /><!--试题id-->
			<div class="queList">
				#foreach($!{paper} in $!{examQuestion.paperList})
				#set($index = ${velocityCount} - 1)
				<div class="que">
					<div class="que_title">
						<span style="color: red;">*</span>&nbsp;<span>$!{paper.name}</span>
					</div>
					<div class="anw">
						<input type="hidden" name="detailList[$!{index}].examPaper.id" value="$!{paper.id}" />
						#foreach($!{answer} in $!{paper.answerList})
						<div class="anwitem">
							<div>
								<input type="radio" name="detailList[$!{index}].myAnswer.id"  value="$!{answer.id}" />
							</div>
							<div class="anw_text">
								$!{answer.serialNumber}
								<span class="val">${answer.context}</span>
							</div>
						</div>
						#end
					</div>
				</div>
				#end
			</div>
			<div class="but">
				<span>提交</span>
			</div>
			</form>
		</div>
	</body>
</html>
<script src="$!{basePath}/app/js/jquery-2.1.4.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
	$(".anwitem").bind("click", function(){
		$(this).find("input").prop("checked",true)
	})

	function getQueryVariable(variable){
		var query = window.location.search.substring(1);
		var vars = query.split("&");
		for (var i=0;i<vars.length;i++) {
			var pair = vars[i].split("=");
			if(pair[0] == variable){return pair[1];}
		}
		return(false);
	}

	var courseId = getQueryVariable('courseId');

	$(".but").click(function(){
		var d = {};
		var t = $('form').serializeArray();
		$.each(t, function() {
			d[this.name] = this.value;
		});
		console.log(d);
		$.ajax({
			url: "$!{basePath}/system/back/poster/examResult/doAdd.do",
			type: "post",
			data: d,
			success: function (data) {
				var timestamp = new Date().getTime();
				if(data.success) {
					window.location.href = "$!{basePath}/system/back/poster/examResult/toResult.do?courseId="+ courseId+ "&dataTime=" + timestamp;
				}
			},
			error: function(data) {

			}
		});
	})


</script>